package my.iterator;

import java.util.Iterator;
//餐厅菜单 迭代器
public class DinerMenuIterator implements Iterator {
    private final MenuItem[] menuItems;
    private int position = 0;

    public DinerMenuIterator(MenuItem[] menuItems) {
        this.menuItems = menuItems;
    }

    @Override
    public boolean hasNext() {
        if (position >= menuItems.length || menuItems[position] == null) {
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        return menuItems[position++];
    }


}
